<template>
  <el-dialog
    @open="handleOpen"
    @close="handleClose()"
    :title="title"
    :visible="dialogVisible"
    width="80%"
  >
    <el-form
      :model="postData"
      :rules="postRules"
      label-width="80px"
      label-position="left"
      ref="postForm"
    >
      <el-row>
        <el-col :span="12">
          <el-form-item prop="title" label="标题">
            <el-input v-model="postData.title" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item prop="houseId" label="房子">
            <el-select v-model="postData.houseId">
              <el-option
                v-for="item in houseListMy"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item prop="content" label="内容">
            <el-input type="textarea" v-model="postData.content" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item prop="imgs" label="相关照片">
            <upload-more ref="upload" :file-list="postData.imgs" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer">
      <el-button @click="cancel">取 消</el-button>
      <el-button
        @click="(postData.imgs = $refs.upload.getFiles().join()), submit()"
        type="primary"
        >提 交</el-button
      >
    </div>
  </el-dialog>
</template>

<script>
import postDialog from "../../../mixins/postDialog";
import getHouseListMy from "../../../mixins/getHouseListMy";
import uploadMore from "../../../components/UploadMore/uploadMore";

export default {
  name: "postDialog",
  mixins: [postDialog, getHouseListMy],
  components: { uploadMore },
  data() {
    return {
      postData: {
        title: "",
        content: "",
        imgs: "",
        houseId: ""
      },
      postRules: {
        title: [{ required: true, message: "请输入标题", trigger: "blur" }],
        content: [{ required: true, message: "请输入内容", trigger: "blur" }]
      },
      addUrl: "/api/comment/comment"
    };
  }
};
</script>

<style scoped></style>
